<%@ Page language="c#" Codebehind="Properties.aspx.cs" AutoEventWireup="True" Inherits="CrossFactory.SiteNote.XmlEditor.Properties" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<html>
	<head>
		<title>
			<%= pageResourceManager.GetString("pagetitle")%>
		</title>
    <script src="../JScript/jquery-1.4.2.min.js" type="text/javascript"></script>
		<link href="StyleSheets/XmlEditor.css" type="text/css" rel="stylesheet" />
			<script language="javascript" src="HierarchyManager.js" type="text/javascript"></script>
			<script language="javascript" src="../Admin/Scripts/popcalendar.aspx" type="text/javascript"></script>
			<script language="javascript" type="text/javascript">
			var xmlEditor;
			var hierarchyManager;
			var content;
			var properties;
			var dialog = null;
			var currentPropertyId = null;
			var currentFileUri = null;
			var currentId;
			var field;
			var currentItemsList = null;
			var currentDataSource = null;
			var bFileUploaded = false;
			var bItemsUploaded = false;
			var bDataSourceUploaded = false;
			var currentSizeWidth = null;
			var currentSizeHeight = null;
			
			
			function Loaded()
			{
				var curId;
				var node;
				var children;
				var child;
				var label;
				var xeId;
				var html;
				var bFound;
				var isProperty;
				var curHeight;
				var curWidth;
				var enumeration;
				var fileUri;
				var address;
				var pos;
				var type;
				//var bOpenWin;
				var bOpenDialog;
				var dataType;
				
				try
				{
				    
				    //bOpenWin = false;
				    xmlEditor = dialogArguments;
				    bOpenDialog = true;

				    hierarchyManager = new HierarchyManager(<%# ManagerParameters %>);
    				
				    content = document.all["content"];
    				
				    if (xmlEditor.element.highlightedElement != null)
				    {
					    curId = xmlEditor.element.highlightedElement.xe_id;
				    }
				    else
				    {
					    curId = xmlEditor.element.currentId;
				    }
    				
				    currentId = curId;
    				
				    node = xmlEditor.xmlDocument.selectSingleNode("//*[@xe:id = '" + curId + "']");

				    bFound = false;

				    properties = new Array();

				    if (node != null)
				    {
					    if (node.nodeName != 'field')
					    {
						    html = '<table border="0" cellpadding="0" cellspacing="0" height="100%" width="100%">';
						    children = node.childNodes;

						    for(var idx = 0; idx < children.length; idx++)
						    {
							    child = children.item(idx);

							    if (child.nodeType == 1)
							    {
    								
								    xeId = child.attributes.getNamedItem('xe:id');
								    label = child.attributes.getNamedItem('xe:label');
								    isProperty = child.attributes.getNamedItem('xe:property');
								    hasEnumeration = child.attributes.getNamedItem('xe:hasEnumeration');
								    schemaType = child.attributes.getNamedItem('xe:schemaType');
								    hyperlinkType = child.attributes.getNamedItem('xe:hyperlinkType');
								    dataType = child.attributes.getNamedItem('xe:dataType');
    								
								    if (isProperty != null)
								    {
									    if (isProperty.text == 'True')
									    {
										    properties[properties.length] = xeId.text;
    										
										    if (hasEnumeration.text == 'True')
										    {
											    enumeration = xmlEditor.svcHelper.GetEnumeration(xmlEditor.documentId, schemaType.text);

											    if (enumeration != null)
											    {
												    html += '<tr><td class="label"><nobr>' + xmlEditor.GetLabelElement(label.text) + '</nobr></td><td class="label">&nbsp;:&nbsp;</td><td class="value">';
												    html += '<select id="xe_' + xeId.text +  '" class="value">';
												    for(var i = 0; i < enumeration.childNodes.length; i++)
												    {
													    html += '<option value="' + enumeration.childNodes.item(i).text + '"';
													    if (enumeration.childNodes.item(i).text == child.text)
													    {
														    html += 'SELECTED';
													    }
													    html += '>' + xmlEditor.GetLabelElement(enumeration.childNodes.item(i).text) + '</option>';
												    }
												    html += '</select></td></tr>';
												    html += '</td></tr>';
											    }
											    else
											    {
												    html += '<tr><td class="label"><nobr>' + xmlEditor.GetLabelElement(label.text) + '</nobr></td><td class="label">&nbsp;:&nbsp;</td><td class="value" colspan="2"><input id="xe_' + xeId.text +  '" type="text" class="value" value="' + child.text.replace(/\"/g, '&quot;') + '"></input></td></tr>';
											    }
										    }
										    else
										    {
    										
											    if (hyperlinkType == null)
											    {
											        if(dataType == null)
											        {
												        if (label.text == 'constraints')
												        {
													        properties.splice(properties.length - 1,1);
													        childrenConstraints = child.childNodes;

													        for(var idx2 = 0; idx2 < childrenConstraints.length; idx2++)
													        {
														        childConstraints = childrenConstraints.item(idx2);

														        if (childConstraints.nodeType == 1)
														        {
															        xeId = childConstraints.attributes.getNamedItem('xe:id');
															        label = childConstraints.attributes.getNamedItem('xe:label');
															        isProperty = childConstraints.attributes.getNamedItem('xe:property');
															        hasEnumeration = childConstraints.attributes.getNamedItem('xe:hasEnumeration');
															        schemaType = childConstraints.attributes.getNamedItem('xe:schemaType');
															        hyperlinkType = childConstraints.attributes.getNamedItem('xe:hyperlinkType');
        															
															        html += '<tr><td class="label"><nobr>' + xmlEditor.GetLabelElement(label.text) + '</nobr></td><td class="label">&nbsp;:&nbsp;</td><td class="value" colspan="2"><input id="xe_' + xeId.text +  '" type="text" class="value" value="' + childConstraints.text.replace(/\"/g, '&quot;') + '"></input></td></tr>';
        															
															        properties[properties.length] = xeId.text;

														        }
													        }
												        }
												        else
												        {
													        html += '<tr><td class="label"><nobr>' + xmlEditor.GetLabelElement(label.text) + '</nobr></td><td class="label">&nbsp;:&nbsp;</td><td class="value" colspan="2"><input id="xe_' + xeId.text +  '" type="text" class="value" value="' + child.text.replace(/\"/g, '&quot;') + '"></input></td></tr>';
													        if (label.text == "width")
													        {
														        currentSizeWidth = xeId.text;
													        }
													        if (label.text == "height")
													        {
														        currentSizeHeight = xeId.text;
													        }
												        }
												    }
												    else
												    {
												        switch(dataType.value)
												        {
													        case 'datetime':
													            var currHeight = parseInt(window.dialogHeight);
				                                                var currWidth = parseInt(window.dialogWidth);
                                                				
				                                                window.dialogHeight = currHeight + 150 + 'px';
				                                                window.dialogWidth = currWidth + 110 +'px';
													            html += '<tr valign="top"><td class="label"><nobr>' + xmlEditor.GetLabelElement(label.text) + '</nobr></td><td class="label">&nbsp;:&nbsp;</td><td class="label"><input type="text" id="xe_date_' + xeId.text +  '" class="value" readonly style="width:160px" value="' + child.text + '"></td><td class="value"><img src="../Admin/Images/DatePicker/calendar.jpg" width="18px" height="17px" alt="' + xmlEditor.GetLabelEditor('choosedate') + '" onclick="return showCalendar(this,document.getElementById(\'xe_date_' + xeId.text + '\'), \'dd/MM/yyyy\', \'en\', 1,-1,-1,-1 );" /></td></tr>';
													            break;
													        default:
													        break;
													    }
												    }
											    }
											    else
											    {
												    switch(hyperlinkType.value)
												    {
													    case 'www,page':
														    address = '';
														    if (child.text != '')
														    {
															    pos = child.text.indexOf(':');
    															
															    if (pos != -1)
															    {
																    type = child.text.substr(0, pos);

																    switch(type.toLowerCase())
																    {
																	    case 'cm':
																		    address = hierarchyManager.GetUrl(child.text.substr(pos + 1));
																		    if (address != null)
																		    {
																			    if (address.substr(0, hierarchyManager.baseUrl.length).toLowerCase() == hierarchyManager.baseUrl.toLowerCase())
																			    {
																				    address = address.substr(hierarchyManager.baseUrl.length - 1);
																			    }
																		    }
																		    else
																		    {
																			    address = '';
																		    }
																	    break;
																	    case 'http':
																		    address = child.text;
																	    break;
																    }
    																
															    }
															    else
															    {
																    address = child.text;
															    }
														    }
														    else
														    {
														    }
														    html += '<tr><td class="label"><nobr>' + xmlEditor.GetLabelElement(label.text) + '</nobr></td><td class="label">&nbsp;:&nbsp;</td><td class="label"><input type="text" id="xe_value_' + xeId.text +  '" class="value" style="width:160" value="' + address + '" onchange="onChange();"></td><td class="value"><input id="xe_' + xeId.text +  '" type="hidden" value="' + child.text + '"></input><input type="button" value="' + xmlEditor.GetLabelEditor('choosepage') + '" onclick="UpdatePage(\'' + xeId.text + '\', \'' + hyperlinkType.value + '\')" style="width:140"></td></tr>';
    														
														    break;
													    case 'www':
														    address = '';
														    if (child.text != '')
														    {
															    pos = child.text.indexOf(':');
    															
															    if (pos != -1)
															    {
																    type = child.text.substr(0, pos);

																    switch(type.toLowerCase())
																    {
																	    case 'http':
																		    address = child.text;
																	    break;
																    }
    																
															    }
															    else
															    {
																    address = child.text;
															    }
														    }
														    else
														    {
    														
														    }
														    html += '<tr><td class="label"><nobr>' + xmlEditor.GetLabelElement(label.text) + '</nobr></td><td class="label">&nbsp;:&nbsp;</td><td class="label"><input type="text" id="xe_value_' + xeId.text +  '" class="value" style="width:160" value="' + address + '" onchange="onChange();"></td><td class="value"><input id="xe_' + xeId.text +  '" type="hidden" value="' + child.text + '"></input></td></tr>';
    														
														    break;
													    case 'www,page,file':
														    address = '';
														    if (child.text != '')
														    {
															    pos = child.text.indexOf(':');
    															
															    if (pos != -1)
															    {
																    type = child.text.substr(0, pos);

																    switch(type.toLowerCase())
																    {
																	    case 'cm':
																		    address = hierarchyManager.GetUrl(child.text.substr(pos + 1));

																		    if (address != null)
																		    {
																			    if (address.substr(0, hierarchyManager.baseUrl.length).toLowerCase() == hierarchyManager.baseUrl.toLowerCase())
																			    {
																				    address = address.substr(hierarchyManager.baseUrl.length - 1);
																			    }
																		    }
																		    else
																		    {
																			    address = '';
																		    }
																	    break;
																	    case 'file':
																		    address = '<%= Application["ApplicationPath"] %>' + child.text.substr(pos + 1);
																	    break;
																	    case 'http':
																		    address = child.text;
																	    break;
																    }
															    }
															    else
															    {
																    address = child.text;
															    }
														    }
														    html += '<tr><td class="label"><nobr>' + xmlEditor.GetLabelElement(label.text) + '</nobr></td><td class="label">&nbsp;:&nbsp;</td><td class="label"><input type="text" id="xe_value_' + xeId.text +  '" class="value" style="width:160" value="' + address + '" onchange="onChange();"></td><td class="value"><input id="xe_' + xeId.text +  '" type="hidden" value="' + child.text + '"></input><input type="button" value="' + xmlEditor.GetLabelEditor('chooselink') + '" onclick="UpdatePage(\'' + xeId.text + '\', \'' + hyperlinkType.value + '\')" style="width:140"></td></tr>';
    														
														    break;
													    case 'page':
														    address = '';
														    if (child.text != '')
														    {
															    pos = child.text.indexOf(':');
    															
															    if (pos != -1)
															    {
																    address = hierarchyManager.GetUrl(child.text.substr(pos + 1));
    																
																    if (address != null)
																    {
																	    if (address.substr(0, hierarchyManager.baseUrl.length).toLowerCase() == hierarchyManager.baseUrl.toLowerCase())
																	    {
																		    address = address.substr(hierarchyManager.baseUrl.length - 1);
																	    }
    																	
																    }
																    else
																    {
																	    address = '';
																    }
															    }
															    else
															    {
																    address = child.text;
															    }
														    }
														    //html += '<tr><td class="label"><nobr>' + xmlEditor.GetLabelElement(label.text) + '</nobr></td><td class="label">&nbsp;:&nbsp;</td><td class="label"><input type="text" id="xe_value_' + xeId.text +  '" DISABLED class="value" style="width:100%" value="' + address + '"></td><td class="value"><input id="xe_' + xeId.text +  '" type="hidden" value="' + child.text + '"></input><input type="button" value="' + xmlEditor.GetLabelEditor('choosepage') + '" onclick="UpdatePage(\'' + xeId.text + '\')"></td></tr>';
														    html += '<tr><td class="label"><nobr>' + xmlEditor.GetLabelElement(label.text) + '</nobr></td><td class="label">&nbsp;:&nbsp;</td><td class="label"><input type="text" id="xe_value_' + xeId.text +  '" DISABLED class="value" style="width:160" value="' + address + '"></td><td class="value"><input id="xe_' + xeId.text +  '" type="hidden" value="' + child.text + '"></input><input type="button" value="' + xmlEditor.GetLabelEditor('choosepage') + '" onclick="UpdatePage(\'' + xeId.text + '\')" style="width:140"></td></tr>';
														    break;
													    case 'localImage':
														    if (child.text == '' && bOpenDialog)
														    {
															    if (dialog == null)
															    {
																    fileUri = xmlEditor.documentUri;
																    if (fileUri.lastIndexOf("/") != -1)
																    {
																	    fileUri = fileUri.substring(0, fileUri.lastIndexOf("/"));
																    }
																    fileUri += "/img_" + xeId.text;
																    if (<%= ShowUploadFileIfEmpty %> /*&& !bOpenWin*/)
																    {
																	    ShowUpdateFileWindow(xeId.text, fileUri, 'image');
																	    //alert('localImage');
																	    //bOpenWin = true;
																    }
															    }
															    //html += '<tr><td class="label"><nobr>' + xmlEditor.GetLabelElement(label.text) + '</nobr></td><td class="label">&nbsp;:&nbsp;</td><td class="value" colspan="2"><input id="xe_' + xeId.text +  '" type="hidden" value="' + child.text + '"></input><input type="button" value="' + xmlEditor.GetLabelEditor('update') + '" onclick="UpdateFile(\'' + xeId.text + '\', \'image\')"><input type="button" value="' + xmlEditor.GetLabelEditor('clear') + '" onclick="ClearFile(\'' + xeId.text + '\', \'image\')"></td></tr>';
															    //html += '<tr height="40"><td class="label" valign="middle"><nobr>' + xmlEditor.GetLabelElement(label.text) + '</nobr></td><td class="label" valign="middle">&nbsp;:&nbsp;</td><td class="value" valign="middle"><input id="xe_' + xeId.text +  '" type="hidden" value="' + child.text + '"></input><input type="button" value="' + xmlEditor.GetLabelEditor('update') + '" onclick="UpdateFile(\'' + xeId.text + '\', \'image\')"><input type="button" value="' + xmlEditor.GetLabelEditor('clear') + '" onclick="ClearFile(\'' + xeId.text + '\', \'image\')"></td><td><div style="width:150px;overflow:hidden;"><img id="xe_' + xeId.text +  '_Preview" onclick="PreviewImage(\'' + xeId.text + '\');" alt="' + xmlEditor.GetLabelEditor('preview') + '"  src="' + xmlEditor.xmlEditorPath + 'ImageThumbnail.aspx?uri=' +  xmlEditor.documentProviderName + ':' + child.text + '" height="40" style="display:none;" /></div></td></tr>';															
    															
															    if(child.text != '')
															    {
															    //alert('1');
															        html += '<tr height="40"><td class="label" valign="middle"><nobr>' + xmlEditor.GetLabelElement(label.text) + '</nobr></td><td class="label" valign="middle">&nbsp;:&nbsp;</td><td class="value" valign="middle"><input id="xe_' + xeId.text +  '" type="hidden" value="' + child.text + '"></input><input type="button" value="' + xmlEditor.GetLabelEditor('update') + '" onclick="UpdateFile(\'' + xeId.text + '\', \'image\')"><input type="button" value="' + xmlEditor.GetLabelEditor('clear') + '" onclick="ClearFile(\'' + xeId.text + '\', \'image\')"></td><td><div style="width:150px;overflow:hidden;"><img id="xe_' + xeId.text +  '_Preview" onclick="PreviewImage(\'' + xeId.text + '\');" alt="' + xmlEditor.GetLabelEditor('preview') + '"  src="../WWW/GetFile.aspx?uri=' + ':' + GetURI(child.text) + '" height="40" style="display:none;" /></div></td></tr>';
															    }
															    else
															    {
															    //alert('2');
															        //html += '<tr height="40"><td class="label" valign="middle"><nobr>' + xmlEditor.GetLabelElement(label.text) + '</nobr></td><td class="label" valign="middle">&nbsp;:&nbsp;</td><td class="value" valign="middle"><input id="xe_' + xeId.text +  '" type="hidden" value="' + child.text + '"></input><input type="button" value="' + xmlEditor.GetLabelEditor('update') + '" onclick="UpdateFile(\'' + xeId.text + '\', \'image\')"><input type="button" value="' + xmlEditor.GetLabelEditor('clear') + '" onclick="ClearFile(\'' + xeId.text + '\', \'image\')"></td><td><div style="width:150px;overflow:hidden;"></div></td></tr>';
															        html += '<tr height="40"><td class="label" valign="middle"><nobr>' + xmlEditor.GetLabelElement(label.text) + '</nobr></td><td class="label" valign="middle">&nbsp;:&nbsp;</td><td class="value" valign="middle"><input id="xe_' + xeId.text +  '" type="hidden" value="' + child.text + '"></input><input type="button" value="' + xmlEditor.GetLabelEditor('update') + '" onclick="UpdateFile(\'' + xeId.text + '\', \'image\')"><input type="button" value="' + xmlEditor.GetLabelEditor('clear') + '" onclick="ClearFile(\'' + xeId.text + '\', \'image\')"></td><td><div style="width:150px;overflow:hidden;"><img id="xe_' + xeId.text +  '_Preview" onclick="PreviewImage(\'' + xeId.text + '\');" alt="' + xmlEditor.GetLabelEditor('preview') + '"  src="../WWW/GetFile.aspx?uri=' + ':<%= Application["ApplicationPath"] %>_SiteNote/Admin/Images/Transp.gif" height="40" style="display:none;" /></div></td></tr>';
															    }
														    }
														    else
														    {
															    bOpenDialog = false;
															    //alert('../WWW/GetFile.aspx?uri=' + ':' + child.text);
															    //html += '<tr><td class="label" valign="middle"><nobr>' + xmlEditor.GetLabelElement(label.text) + '</nobr></td><td class="label" valign="middle">&nbsp;:&nbsp;</td><td class="value" colspan="2"><input id="xe_' + xeId.text +  '" type="hidden" value="' + child.text + '"></input><input type="button" value="' + xmlEditor.GetLabelEditor('update') + '" onclick="UpdateFile(\'' + xeId.text + '\', \'image\')"><input type="button" value="' + xmlEditor.GetLabelEditor('clear') + '" onclick="ClearFile(\'' + xeId.text + '\', \'image\')"><img onclick="PreviewImage(\'' + xeId.text + '\');" alt="' + xmlEditor.GetLabelEditor('preview')"  + '" src="' + xmlEditor.xmlEditorPath + 'ImageThumbnail.aspx?uri=' +  xmlEditor.documentProviderName + ':' + child.text + '" height="40" /></td></tr>';
															    //html += '<tr height="40"><td class="label" valign="middle"><nobr>' + xmlEditor.GetLabelElement(label.text) + '</nobr></td><td class="label" valign="middle">&nbsp;:&nbsp;</td><td class="value" valign="middle"><input id="xe_' + xeId.text +  '" type="hidden" value="' + child.text + '"></input><input type="button" value="' + xmlEditor.GetLabelEditor('update') + '" onclick="UpdateFile(\'' + xeId.text + '\', \'image\')"><input type="button" value="' + xmlEditor.GetLabelEditor('clear') + '" onclick="ClearFile(\'' + xeId.text + '\', \'image\')"></td><td><div style="width:150px;overflow:hidden;"><img id="xe_' + xeId.text +  '_Preview" onclick="PreviewImage(\'' + xeId.text + '\');" alt="' + xmlEditor.GetLabelEditor('preview') + '" src="' + xmlEditor.xmlEditorPath + 'ImageThumbnail.aspx?uri=' +  xmlEditor.documentProviderName + ':' + child.text + '" height="40" /></div></td></tr>';
															    if(child.text != '')
															    {		
															    //alert('3');													
															        html += '<tr height="40"><td class="label" valign="middle"><nobr>' + xmlEditor.GetLabelElement(label.text) + '</nobr></td><td class="label" valign="middle">&nbsp;:&nbsp;</td><td class="value" valign="middle"><input id="xe_' + xeId.text +  '" type="hidden" value="' + child.text + '"></input><input type="button" value="' + xmlEditor.GetLabelEditor('update') + '" onclick="UpdateFile(\'' + xeId.text + '\', \'image\')"><input type="button" value="' + xmlEditor.GetLabelEditor('clear') + '" onclick="ClearFile(\'' + xeId.text + '\', \'image\')"></td><td><div style="width:150px;overflow:hidden;"><img id="xe_' + xeId.text +  '_Preview" onclick="PreviewImage(\'' + xeId.text + '\');" alt="' + xmlEditor.GetLabelEditor('preview') + '" src="../WWW/GetFile.aspx?uri=' + ':' + GetURI(child.text) + '" height="40" /></div></td></tr>';
															    }
															    else
															    {
															    //alert('4');
															        //html += '<tr height="40"><td class="label" valign="middle"><nobr>' + xmlEditor.GetLabelElement(label.text) + '</nobr></td><td class="label" valign="middle">&nbsp;:&nbsp;</td><td class="value" valign="middle"><input id="xe_' + xeId.text +  '" type="hidden" value="' + child.text + '"></input><input type="button" value="' + xmlEditor.GetLabelEditor('update') + '" onclick="UpdateFile(\'' + xeId.text + '\', \'image\')"><input type="button" value="' + xmlEditor.GetLabelEditor('clear') + '" onclick="ClearFile(\'' + xeId.text + '\', \'image\')"></td><td><div style="width:150px;overflow:hidden;"></div></td></tr>';
															        html += '<tr height="40"><td class="label" valign="middle"><nobr>' + xmlEditor.GetLabelElement(label.text) + '</nobr></td><td class="label" valign="middle">&nbsp;:&nbsp;</td><td class="value" valign="middle"><input id="xe_' + xeId.text +  '" type="hidden" value="' + child.text + '"></input><input type="button" value="' + xmlEditor.GetLabelEditor('update') + '" onclick="UpdateFile(\'' + xeId.text + '\', \'image\')"><input type="button" value="' + xmlEditor.GetLabelEditor('clear') + '" onclick="ClearFile(\'' + xeId.text + '\', \'image\')"></td><td><div style="width:150px;overflow:hidden;"><img id="xe_' + xeId.text +  '_Preview" onclick="PreviewImage(\'' + xeId.text + '\');" alt="' + xmlEditor.GetLabelEditor('preview') + '" src="../WWW/GetFile.aspx?uri=' + ':<%= Application["ApplicationPath"] %>_SiteNote/Admin/Images/Transp.gif" height="40" /></div></td></tr>';
															    }
														    }
														    break;
													    case 'localFile':
														    if (child.text == '')
														    {
															    if (dialog == null && bOpenDialog/*&& !bOpenWin */)
															    {
																    fileUri = xmlEditor.documentUri;
																    if (fileUri.lastIndexOf("/") != -1)
																    {
																	    fileUri = fileUri.substring(0, fileUri.lastIndexOf("/"));
																    }
																    fileUri += "/file_" + xeId.text;
																    ShowUpdateFileWindow(xeId.text, fileUri, 'file');
															        
																    /*alert('localFile');
																    bOpenWin = true;*/
															    }
														    }
														    else
														    {
															    bOpenDialog = false;
														    }
														    html += '<tr><td class="label"><nobr>' + xmlEditor.GetLabelElement(label.text) + '</nobr></td><td class="label">&nbsp;:&nbsp;</td><td class="value" colspan="2"><input id="xe_' + xeId.text +  '" type="hidden" value="' + child.text + '"></input><input type="button" value="' + xmlEditor.GetLabelEditor('update') + '" onclick="UpdateFile(\'' + xeId.text + '\', \'file\')"></td></tr>';
														    break;
													    case 'wf_activity':
														    var node;
														    var activities;
														    var options = "";
														    var activityId;
														    var activityDesc;
    														
														    activities = xmlEditor.xmlDocument.selectNodes("//activity")
														    for(var idx = 0; idx < activities.length; idx++)
														    {
															    activityId = activities.item(idx).selectSingleNode("id").text;
															    activityDesc = activities.item(idx).selectSingleNode("description").text;
    															
															    if (activityDesc == "")
															    {
																    activityDesc = activityId;
															    }
															    if (activityDesc.length > 50)
															    {
																    activityDesc = activityDesc.substring(0,50);	
															    }
															    if (activityId != "")
															    {
																    if (child.text != '' && child.text == activityId)
																    {
    																
																	    options += '<option value="' + activityId + '" selected>' + activityDesc +  '</option>';
																    }
																    else
																    {
																	    options += '<option value="' + activityId + '">' + activityDesc +  '</option>';
																    }
															    }	
														    }
														    if (child.text != '')
														    {
															    activityId = child.text;
														    }
														    else
														    {
															    options = '<option value="" selected>Choose an activity</option>' + options;
															    activityId = '';
														    }
														    html += '<tr><td class="label"><nobr>' + xmlEditor.GetLabelElement(label.text) + '</nobr></td><td class="label">&nbsp;:&nbsp;</td><td class="label"><span id="xe_value_' + xeId.text +  '" DISABLED class="value" style="width:50%;display:none;">' + activityId + '</span></td><td class="value"><input id="xe_' + xeId.text +  '" type="hidden" value="' + child.text + '"></input><select  id="dropdown_' + xeId.text +  '" onclick="ChangeActivity(\'' + xeId.text + '\')" name="activities" size="1" width="50">' + options + '</select></td></tr>';
														    break;
												    case 'wf_application':
														    var node;
														    var applications;
														    var options = "";
														    var applicationId;
														    var applicationLabel;
    																											
														    applications = xmlEditor.xmlDocument.selectNodes("//applications/application")
														    for(var idx = 0; idx < applications.length; idx++)
														    {
															    applicationId = applications.item(idx).selectSingleNode("id").text;
															    applicationLabel = applications.item(idx).selectSingleNode("label").text;
															    if (applicationLabel == "")
															    {
																    applicationLabel = applicationId;
															    }
															    if (applicationLabel.length > 50)
															    {
																    applicationLabel = applicationLabel.substring(0,50);	
															    }
															    if (applicationId != "")
															    {
																    if (child.text != '' && child.text == applicationId)
																    {
																	    options += '<option value="' + applicationId + '" selected>' + applicationLabel +  '</option>';
																    }
																    else
																    {
																	    options += '<option value="' + applicationId + '">' + applicationLabel +  '</option>';
																    }
															    }	
														    }
														    if (child.text != '')
														    {
															    applicationId = child.text;
														    }
														    else
														    {
															    options = '<option value="" selected>Choose an activity</option>' + options;
															    applicationId = '';
														    }
														    html += '<tr><td class="label"><nobr>' + xmlEditor.GetLabelElement(label.text) + '</nobr></td><td class="label">&nbsp;:&nbsp;</td><td class="label"><span id="xe_value_' + xeId.text +  '" DISABLED class="value" style="width:50%;display:none;">' + applicationId + '</span></td><td class="value"><input id="xe_' + xeId.text +  '" type="hidden" value="' + child.text + '"></input><select  id="dropdown_' + xeId.text +  '" onclick="ChangeApplication(\'' + xeId.text + '\')" name="applications" size="1" width="50">' + options + '</select></td></tr>';
														    break;
												    }
											    }
										    }
    										
										    bFound = true;
									    }
								    }
								    else
								    {
									    //alert('error for : ' + child.xml);
								    }
							    }
						    }
    						
					    }
					    else
					    {
					    /* FIELD */
						    var displayItems = '';
						    var itemsvalue = 'No Items';
						    var datasourcevalue = 'No DataSource';
						    var nodeDataSourceProvider;
						    var nodeItems;
						    field = true;
						    bFound = true;
						    html = '<table border="0" cellpadding="0" cellspacing="0" height="100%" width="100%">';
    						
						    //alert(node.xml);
    							
						    /* name */					
						    child = node.selectSingleNode('name');
						    xeId = child.attributes.getNamedItem('xe:id');
						    label = child.attributes.getNamedItem('xe:label');
						    properties[properties.length] = xeId.text;
						    html += '<tr><td class="label"><nobr>' + xmlEditor.GetLabelElement(label.text) + '</nobr></td><td class="label">&nbsp;:&nbsp;</td><td class="value" colspan="2"><input id="xe_' + xeId.text +  '" type="text" class="value" value="' + child.text.replace(/\"/g, '&quot;') + '"></input></td></tr>';

						    child = node.selectSingleNode('constraints');
						    if (child != null)
						    {
							    childrenConstraints = child.childNodes;

							    for(var idx = 0; idx < childrenConstraints.length; idx++)
							    {
								    childConstraints = childrenConstraints.item(idx);

								    if (childConstraints.nodeType == 1)
								    {
									    xeId = childConstraints.attributes.getNamedItem('xe:id');
									    label = childConstraints.attributes.getNamedItem('xe:label');
									    isProperty = childConstraints.attributes.getNamedItem('xe:property');
									    hasEnumeration = childConstraints.attributes.getNamedItem('xe:hasEnumeration');
									    schemaType = childConstraints.attributes.getNamedItem('xe:schemaType');
									    hyperlinkType = childConstraints.attributes.getNamedItem('xe:hyperlinkType');
    									
									    html += '<tr><td class="label"><nobr>' + xmlEditor.GetLabelElement(label.text) + '</nobr></td><td class="label">&nbsp;:&nbsp;</td><td class="value" colspan="2"><input id="xe_' + xeId.text +  '" type="text" class="value" value="' + childConstraints.text.replace(/\"/g, '&quot;') + '"></input></td></tr>';
    									
									    properties[properties.length] = xeId.text;

								    }
							    }
						    }
						    /* type */
						    child = node.selectSingleNode('type');

						    xeId = child.attributes.getNamedItem('xe:id');
						    label = child.attributes.getNamedItem('xe:label');
						    hasEnumeration = child.attributes.getNamedItem('xe:hasEnumeration');
						    schemaType = child.attributes.getNamedItem('xe:schemaType');
						    properties[properties.length] = xeId.text;

						    enumeration = xmlEditor.svcHelper.GetEnumeration(xmlEditor.documentId, schemaType.text);

						    if (enumeration != null)
						    {
							    html += '<tr><td class="label"><nobr>' + xmlEditor.GetLabelElement(label.text) + '</nobr></td><td class="label">&nbsp;:&nbsp;</td><td class="value">';
							    html += '<select id="xe_' + xeId.text +  '" class="value" onchange="fieldTypeChange(this);">';
							    for(var i = 0; i < enumeration.childNodes.length; i++)
							    {
								    html += '<option value="' + xmlEditor.GetLabelElement(enumeration.childNodes.item(i).text) + '"';
								    if (enumeration.childNodes.item(i).text == child.text)
								    {
									    html += 'SELECTED';
								    }
								    html += '>' + xmlEditor.GetLabelElement(enumeration.childNodes.item(i).text) + '</option>';
							    }
							    html += '</select></td></tr>';
							    html += '</td></tr>';
						    }
    									
						    switch(child.text)
						    {
							    case "text":
							    case "date":
								    displayItems = 'none';
								    break;
							    case "dropdown":
								    displayItems = '';
								    nodeItems = xmlEditor.xmlDocument.selectSingleNode("//*[@xe:id = '" + currentId + "']/items");
								    if (nodeItems == null || nodeItems.childNodes.length == 0)
								    {
									    itemsvalue = 'No Items';
								    }
								    else
								    {
									    itemsvalue = nodeItems.childNodes.length + ' Items';
								    }
								    break;
						    }
    						
						    nodeDataSourceProvider = xmlEditor.xmlDocument.selectSingleNode("//*[@xe:id = '" + currentId + "']/dataSource/provider");
						    if (nodeDataSourceProvider != null)
						    {
							    datasourcevalue = nodeDataSourceProvider.text;
						    }

						    child = node.selectSingleNode('defaultValue');
						    if(child != null)
						    {
							    xeId = child.attributes.getNamedItem('xe:id');
							    label = child.attributes.getNamedItem('xe:label');
							    properties[properties.length] = xeId.text;
							    html += '<tr id="defaultValue"><td class="label"><nobr>' + xmlEditor.GetLabelElement(label.text) + '</nobr></td><td class="label">&nbsp;:&nbsp;</td><td class="value" colspan="2"><input id="xe_' + xeId.text +  '" type="text" class="value" value="' + child.text.replace(/\"/g, '&quot;') + '"></input></td></tr>';
						    }
    				
						    child = node.selectSingleNode('class');
						    if(child != null)
						    {
							    xeId = child.attributes.getNamedItem('xe:id');
							    label = child.attributes.getNamedItem('xe:label');
							    properties[properties.length] = xeId.text;
							    html += '<tr id="class"><td class="label"><nobr>' + xmlEditor.GetLabelElement(label.text) + '</nobr></td><td class="label">&nbsp;:&nbsp;</td><td class="value" colspan="2"><input id="xe_' + xeId.text +  '" type="text" class="value" value="' + child.text.replace(/\"/g, '&quot;') + '"></input></td></tr>';
						    }
    						
						    child = node.selectSingleNode('valuePath');
						    if(child != null)
						    {
							    xeId = child.attributes.getNamedItem('xe:id');
							    label = child.attributes.getNamedItem('xe:label');
							    properties[properties.length] = xeId.text;
							    html += '<tr id="class"><td class="label"><nobr>' + xmlEditor.GetLabelElement(label.text) + '</nobr></td><td class="label">&nbsp;:&nbsp;</td><td class="value" colspan="2"><input id="xe_' + xeId.text +  '" type="text" class="value" value="' + child.text.replace(/\"/g, '&quot;') + '"></input></td></tr>';
						    }
    						
						    child = node.selectSingleNode('mode');
						    if(child != null)
						    {
							    xeId = child.attributes.getNamedItem('xe:id');
							    label = child.attributes.getNamedItem('xe:label');
							    properties[properties.length] = xeId.text;
							    html += '<tr id="class"><td class="label"><nobr>' + xmlEditor.GetLabelElement(label.text) + '</nobr></td><td class="label">&nbsp;:&nbsp;</td><td class="value" colspan="2"><input id="xe_' + xeId.text +  '" type="text" class="value" value="' + child.text.replace(/\"/g, '&quot;') + '"></input></td></tr>';
						    }
    						
						    child = node.selectSingleNode('visibleRows');
						    if(child != null)
						    {
							    xeId = child.attributes.getNamedItem('xe:id');
							    label = child.attributes.getNamedItem('xe:label');
							    properties[properties.length] = xeId.text;
							    html += '<tr id="class"><td class="label"><nobr>' + xmlEditor.GetLabelElement(label.text) + '</nobr></td><td class="label">&nbsp;:&nbsp;</td><td class="value" colspan="2"><input id="xe_' + xeId.text +  '" type="text" class="value" value="' + child.text.replace(/\"/g, '&quot;') + '"></input></td></tr>';
						    }
    						
						    label = "items";
						    html += '<tr id="items" style="display:' + displayItems + ';"><td class="label"><nobr>' + xmlEditor.GetLabelElement(label) + '</nobr></td><td class="label">&nbsp;:&nbsp;</td><td class="label"><span id="items_value" DISABLED class="value" style="width:50%">' + itemsvalue + '</span></td><td class="value"><input class="button" type="button" value="' + xmlEditor.GetLabelEditor('chooseItems') + '" onclick="UpdateItems();"></td></tr>';
						    label = "datasource";
						    html += '<tr id="datasource"><td class="label"><nobr>' + xmlEditor.GetLabelElement(label) + '</nobr></td><td class="label">&nbsp;:&nbsp;</td><td class="label"><span id="datasource_value" DISABLED class="value" style="width:50%">' + datasourcevalue + '</span></td><td class="value"><input class="button" type="button" value="' + xmlEditor.GetLabelEditor('chooseDataSource') + '" onclick="UpdateDataSource();"></td></tr>';
					    }
    									
					    html += '</table>';
				    }
    				
				    if (!bFound)
				    {
					    document.all["Save"].style.display = 'none';
					    html = '<table border="0" cellpadding="0" cellspacing="0" height="100%" width="100%">';
					    html += '<tr><td class="label">There is no property defined for this element.</td></tr>';
					    html += '</table>';
				    }
    	
				    content.innerHTML = html;
    				
				    curHeight = parseInt(window.dialogHeight);
				    curWidth = parseInt(window.dialogWidth);
    				
				    var child = document.getElementById("Main");
				    if(child != undefined)
				    {
				        curHeight = curHeight + child.offsetHeight - document.body.clientHeight;   
				        curWidth = curWidth + child.offsetWidth - document.body.clientWidth;
				    }
				    else
				    {
				        curHeight = curHeight + document.body.firstChild.offsetHeight - document.body.clientHeight;				    
				        curWidth = curWidth + document.body.firstChild.offsetWidth - document.body.clientWidth;
				    }
				    window.dialogHeight = curHeight + 'px';
				    window.dialogWidth = curWidth + 'px';
				}
				catch(e)
				{
				    alert("You were delogged!");
				    Close();
				}
			}
			
			function onChange()
			{
				var obj;
				var hiddenObj;
				var id;
				
				obj = window.event.srcElement;
				
				if(obj != 'undefined')
				{			
					id = obj.id.split('_');
					
					if(id[1] == 'value')
					{
						hiddenObj = document.all['xe_' + id[2]];
						hiddenObj.value = obj.value;
					}					
				}				
			}
			
			function fieldTypeChange(obj)
			{
				window.dialogHeight = '10px'
				var displayItems = '';
				switch(obj.options[obj.selectedIndex].value)
				{
					case "text":
					case "date":
						displayItems = 'none';
						break;
					case "dropdown":
						displayItems = '';
						break;
				}
				//debugger;
				document.all["items"].style.display =  displayItems;
				//document.all["datasource"].style.display =  displayItems;
				curHeight = parseInt(window.dialogHeight);
				curHeight = curHeight + document.body.firstChild.offsetHeight - document.body.clientHeight;
				window.dialogHeight = curHeight + 'px';
			}
			
			function GetURI(text)
			{
			    if(text.indexOf("%2F") < 0)
			    {
			        return encodeURIComponent(text);
			    }
			    return text;
			}
		
			function PreviewImage(propertyId)
			{
				var obj;
				var fileUri;
				obj = document.all['xe_' + propertyId];
				
				if (obj.value != '')
				{
					//filePathUri = xmlEditor.xmlEditorPath + 'ImageThumbnail.aspx?uri=' +  xmlEditor.documentProviderName + ':' + obj.value;
					//alert(obj.value);
					if(obj.value.indexOf("%2F") < 0)
					{
					    filePathUri = '../WWW/GetFile.aspx?uri=' + ':' + encodeURIComponent(obj.value);
					}
					else
					{
					    filePathUri = '../WWW/GetFile.aspx?uri=' + ':' + obj.value;
					}
					window.showModalDialog(window.xmlEditor.xmlEditorPath + 'UploadPreview.aspx', filePathUri, "dialogHeight:450px; dialogWidth:400px; edge: Raised; center: Yes; help: No; scroll:no; resizable: No; status: No;");
				}
			}
			

			function UpdateFile(propertyId, mode)			
			{
				var obj;
				var fileUri;
				
				obj = document.all['xe_' + propertyId];
				
				if (obj.value != '')
				{
					ShowUpdateFileWindow(propertyId, xmlEditor.documentProviderName + ':' + obj.value, mode)
				}
				else
				{
					fileUri = xmlEditor.documentUri;
					fileUri = fileUri.substring(0, fileUri.lastIndexOf("/"));
					
					if (mode == 'image')
					{
						fileUri += "/img_" + propertyId;
					}
					else
					{
						fileUri += "/file_" + propertyId;
					}
					ShowUpdateFileWindow(propertyId, fileUri, mode);
				}
			}
			
			function ClearFile(propertyId, mode)			
			{
				var obj;
				var fileUri;
				
				obj = document.all['xe_' + propertyId];
				
				if (obj.value != '')
				{
					obj.value = '';
				}

				if (document.all['xe_' + propertyId + '_Preview'] != null)
				{
					document.all['xe_' + propertyId + '_Preview'].style.display = 'none';
				}
				
			}
			
			function UpdatePage(propertyId, hyperlinkType)			
			{
				var obj;
				var fileUri;
				
				obj = document.all['xe_' + propertyId];
				
				if (obj.value == '')
				    ShowUpdatePageWindow(propertyId, '<% = ToolbarEditPageName %>', hyperlinkType);
				else
				    ShowUpdatePageWindow(propertyId, obj.value, hyperlinkType);
			}
			
			function UpdateItems()			
			{
				var obj;
				var nodeItems;
				var nodeItem;
				var nodeData;
				var nodeDisplay;
				var childrens;
				var curId;
								
				nodeItems = xmlEditor.xmlDocument.selectNodes("//*[@xe:id = '" + currentId + "']/items/item");
				
				var currentItems = new Array();
				var currentItem; 
				
				for(i = 0; i < nodeItems.length; i ++)
				{
					nodeItem = nodeItems.item(i);
					currentItem = new Array();
					nodeData = nodeItem.selectSingleNode("data");
					nodeDisplay = nodeItem.selectSingleNode("display");
					currentItem[0] = nodeData.text;
					currentItem[1] = nodeDisplay.text;
					currentItems[i] = currentItem
				}
											
				ShowUpdateItemsWindow(currentItems);
			}
			
			function UpdateDataSource()			
			{
				var obj;
				var nodedataSource;
				var nodedataSourceChildrens;
				var nodeData;
				var childrens;
				var curId;
								
				nodedataSource = xmlEditor.xmlDocument.selectSingleNode("//*[@xe:id = '" + currentId + "']/dataSource");
				
				
				var currentDataSource = new Array();
				
				currentDataSource[0] = "";
				currentDataSource[1] = "";
				currentDataSource[2] = "";
				currentDataSource[3] = "";
				currentDataSource[4] = "";
				currentDataSource[5] = "";
				currentDataSource[6] = "";
				currentDataSource[7] = "";
				currentDataSource[8] = "";
				
				if (nodedataSource != null)
				{
					nodeData = nodedataSource.selectSingleNode("provider");
					if (nodeData != null)
					{
						currentDataSource[0] = nodeData.text;
					}
					
					
					nodeData = nodedataSource.selectSingleNode("cachingName");
					if (nodeData != null)
					{
						currentDataSource[1] = nodeData.text;
					}
					
					
					nodeData = nodedataSource.selectSingleNode("select");
					if (nodeData != null)
					{
						currentDataSource[2] = nodeData.text;
					}
					
					
					nodeData = nodedataSource.selectSingleNode("parameter/name");
					if (nodeData != null)
					{
						currentDataSource[3] = nodeData.text;
					}
					
					
					nodeData = nodedataSource.selectSingleNode("parameter/type");
					if (nodeData != null)
					{
						currentDataSource[4] = nodeData.text;
					}
					
					
					nodeData = nodedataSource.selectSingleNode("parameter/value");
					if (nodeData != null)
					{
						currentDataSource[5] = nodeData.text;
					}
					
					
					nodeData = nodedataSource.selectSingleNode("displayColumn");
					if (nodeData != null)
					{
						currentDataSource[6] = nodeData.text;
					}
					
					
					nodeData = nodedataSource.selectSingleNode("filter");
					if (nodeData != null)
					{
						currentDataSource[7] = nodeData.text;
					}
					
					
					nodeData = nodedataSource.selectSingleNode("dataColumn");
					if (nodeData != null)
					{
						currentDataSource[8] = nodeData.text;
					}
				
				}
				ShowUpdateDataSourceWindow(currentDataSource);
			}
			
			function ChangeActivity(propertyId)			
			{
				var obj;
				var fileUri;
				
				obj = document.all['dropdown_' + propertyId];
					
				span = document.all["xe_value_" + propertyId];
				span.innerText = obj.options[obj.selectedIndex].value;
				document.all["xe_" + propertyId].value = obj.options[obj.selectedIndex].value;
			}
			
			function ChangeApplication(propertyId)			
			{
				var obj;
				var fileUri;
				
				obj = document.all['dropdown_' + propertyId];
					
				span = document.all["xe_value_" + propertyId];
				span.innerText = obj.options[obj.selectedIndex].value;
				document.all["xe_" + propertyId].value = obj.options[obj.selectedIndex].value;
			}
			
			function ShowUpdateFileWindow(propertyId, fileUri, mode)
			{
				if (dialog != null)
				{
					if (!dialog.closed)
					{
						dialog.focus();
						return;
					}
					dialog = null;
				}
				currentFileUri = fileUri;
				if (currentSizeWidth != null)
				{
					if(document.all["xe_" + currentSizeWidth] != null)
					{
						currentFileWidth = document.all["xe_" + currentSizeWidth].value;
					}
				}
				if (currentSizeHeight != null)
				{
					if(document.all["xe_" + currentSizeHeight] != null)
					{
						currentFileHeight = document.all["xe_" + currentSizeHeight].value;
					}
				}
				currentPropertyId = propertyId;
				if (xmlEditor.xmlDocument.selectSingleNode("//*[@xe:id = '" + currentId + "']").nodeName == "picturegallery")
				    mode = "gallery";
				dialog = xmlEditor.window.open(xmlEditor.xmlEditorPath + 'Upload.aspx?mode=' + mode, null, "height=200px,width=480px,channelmode=no,directories=no,fullscreen=no,location=no,menubar=no,resizable=no,status=no,scrollbars=yes");
				if(dialog != null)
				{
				    dialog.opener = window;
				    dialog.xmlEditor = xmlEditor;
				    dialog.moveTo((window.screen.availWidth - 400) / 2, (window.screen.availHeight - 150) / 2);
				}
			}
			
			function ShowUpdatePageWindow(propertyId, pageUri, hyperlinkType)
			{
				var result;
				var address;
				var propertyInput;
				var span;
				var pos;
				var type;
				var cmId;
				//debugger;
				if (dialog != null)
				{
					if (!dialog.closed)
					{
						dialog.focus();
						return;
					}
					dialog = null;
				}
				result = hierarchyManager.ChoosePage(hyperlinkType, pageUri);
				
				if (result.returnValue)
				{
  					propertyInput = document.all["xe_" + propertyId];
					span = document.all["xe_value_" + propertyId];

					pos = result.selectedId.indexOf(":");
					
					if (pos != -1)
					{
						type = result.selectedId.substr(0, pos).toLowerCase();
						
						switch(type)
						{
							case "cm":
								cmId = result.selectedId.substr(pos + 1);
								
								address = hierarchyManager.GetUrl(cmId);
								
								if (address != null)
								{
									if (address.substr(0, hierarchyManager.baseUrl.length).toLowerCase() == hierarchyManager.baseUrl.toLowerCase())
									{
										address = address.substr(hierarchyManager.baseUrl.length - 1);
									}

									propertyInput.value = result.selectedId;
									span.innerText = address;
								}
								break;
							case "file":
								address = result.selectedId.replace(/&/, "&amp;");
								address = address.replace(/</, "&lt;");
								address = address.replace(/>/, "&gt;");
								
								propertyInput.value = address;
								address = address.substr(pos + 1);
								span.innerText = '<%= Application["ApplicationPath"] %>' + address;
								
								
						}
					}
				}
			}
			
			
			function ShowUpdateItemsWindow(itemsList)
			{
				if (dialog != null)
				{
					if (!dialog.closed)
					{
						dialog.focus();
						return;
					}
					dialog = null;
				}
							
				currentItemsList = itemsList;
				
				result = window.showModalDialog(xmlEditor.xmlEditorPath + 'Items.aspx', currentItemsList, "dialogHeight:450px; dialogWidth:400px; edge: Raised; center: Yes; help: No; scroll:no; resizable: No; status: No;");
				if (result)
				{
					document.all["items_value"].innerHTML = currentItemsList.length + ' Items';
					bItemsUploaded = true;
				}
				else
				{
					currentItemsList = null;
				}
			}
			
			function ShowUpdateDataSourceWindow(dataSource)
			{
				if (dialog != null)
				{
					if (!dialog.closed)
					{
						dialog.focus();
						return;
					}
					dialog = null;
				}
					
				currentDataSource = dataSource;
				
				result = window.showModalDialog(xmlEditor.xmlEditorPath + 'DataSource.aspx', currentDataSource, "dialogHeight:450px; dialogWidth:700px; edge: Raised; center: Yes; help: No; scroll:no; resizable: No; status: No;");
				if (result)
				{
					document.all["datasource_value"].innerHTML = currentDataSource[0];
					bDataSourceUploaded = true;
				}
				else
				{
					currentDataSource = null;
				}
			}
			
			
			function Close()
			{
				xmlEditor.dialog = null;
				xmlEditor.ProcessMouseOut();

				if (dialog != null)
				{
					if (!dialog.closed)
					{
						dialog.close();
					}
					dialog = null;
				}

				if (bFileUploaded)
				{
					xmlEditor.UpdateHTML();
					bFileUploaded = false;
				}
				
				if (bItemsUploaded)
				{
					xmlEditor.UpdateHTML();
					bItemsUploaded = false;
				}
				
				if (bDataSourceUploaded)
				{
					xmlEditor.UpdateHTML();
					bDataSourceUploaded = false;
				}

				window.close();
			}
			
			function Save()
			{
				var idx;
				var propertyNode;
				var propertyInput;
				var linkType;
				
				if (dialog != null)
				{
					if (!dialog.closed)
					{
						dialog.focus();
						return;
					}
					dialog = null;
				}
			
				for (idx in properties)
				{
				
					propertyNode = xmlEditor.xmlDocument.selectSingleNode("//*[@xe:id = '" + properties[idx] + "']");
					propertyInput = document.all["xe_" + properties[idx]];
					
					if(propertyInput != undefined)
					{
					    if(propertyNode.parentNode != undefined)
					    {
					        if(propertyNode.nodeName == "step" || (propertyNode.nodeName == "name" && propertyNode.parentNode.nodeName == "form-stepelement"))
					        {
					            propertyNode.text = propertyInput.value.toLowerCase();
					        }
					        else
					        {
					            if(propertyNode.nodeName.toLowerCase().indexOf('uri') != -1)
					            {
					                propertyNode.text = GetURI(propertyInput.value);
					            }
					            else
					            {
					                propertyNode.text = propertyInput.value;
					            }
					        }
					    }
					    else
					    {
					        if(propertyNode.nodeName == "step")
					        {
					            propertyNode.text = propertyInput.value.toLowerCase();
					        }
					        else
					        {
					            if(propertyNode.nodeName.toLowerCase().indexOf('uri') != -1)
					            {
					                propertyNode.text = encodeURIComponent(propertyInput.value);
					            }
					            else
					            {
					                propertyNode.text = propertyInput.value;
					            }
					        }
					    }
					    
					    xmlEditor.svcHelper.SaveText(xmlEditor.documentId, properties[idx], propertyNode.xml);						
					}
					else
					{
					    propertyInput = document.all["xe_date_" + properties[idx]];
					    if(propertyInput != undefined)
					    {
					        propertyNode.text = propertyInput.value;
					        xmlEditor.svcHelper.SaveText(xmlEditor.documentId, properties[idx], propertyNode.xml);						
					    }
					}
				}
				
				if (field)
				{
					var typeNode;
					
					typeNode = xmlEditor.xmlDocument.selectSingleNode("//*[@xe:id = '" + currentId + "']/type");
					
					if (typeNode != null)
					{
						type = typeNode.text;
						switch(type)
						{
							case 'text':
							case 'date':
								DeleteNodeItems();
								break;
							case 'dropdown':
								if (bItemsUploaded)
								{
									SaveItemsList();
								}
								break;							
						}
						if (bDataSourceUploaded)
						{
							SaveDataSource();
						}
					}
				}
				
				bFileUploaded = false;
				bItemsUploaded = false;
				bDataSourceUploaded = false;
				xmlEditor.dialog = null;
				xmlEditor.ProcessMouseOut();

				xmlEditor.UpdateHTML();

				window.close();
			}
			
			function DeleteNodeItems()
			{
				var nodeItems;
				nodeItems = xmlEditor.xmlDocument.selectSingleNode("//*[@xe:id = '" + currentId + "']/items");
				
				if (nodeItems != null)
				{
					id = nodeItems.attributes.getNamedItem("xe:id").text;
					xmlEditor.svcHelper.DeleteElement(xmlEditor.documentId, id);
				}
			}
			
			function SaveItemsList()
			{
				var nodeItems;
				var nodeItem;
				var nodeData;
				var nodeDisplay;
				var childrens;
				var childrensOld;
				var nbChildrensOld;
				var id;
				var nodeItemsId;
				var newXmlDocument;
				
				nodeItems = xmlEditor.xmlDocument.selectSingleNode("//*[@xe:id = '" + currentId + "']/items");
				
				if (nodeItems == null)
				{
					nbChildrensOld = 0;
					result = xmlEditor.svcHelper.CreateElement(xmlEditor.documentId, currentId, 'inside', 'items', 'items', 'SOMITEM_COMPLEXTYPE');				
					
					/* MsXml modif */
					newXmlDocument = new ActiveXObject("Msxml2.DOMDocument");
					
					newXmlDocument.async = false;
					newXmlDocument.resolveExternals = true;
					newXmlDocument.setProperty("AllowXsltScript", true);
                    newXmlDocument.setProperty("AllowDocumentFunction", true);
					newXmlDocument.loadXML(result);
							
					nodeItems = newXmlDocument.selectSingleNode("//*[@xe:id = '" + currentId + "']/items");
				}
				else
				{							
					childrensOld = nodeItems.childNodes;
					nbChildrensOld = childrensOld.length;
				}
				
				nodeItemsId = nodeItems.attributes.getNamedItem("xe:id").text;
										
				for(i = 0; i < currentItemsList.length; i++)
				{
					if (i < nbChildrensOld)
					{
						/* modify Item */
						nodeItem = childrensOld.item(i);
					}
					else
					{
						/* create Item */
						result = xmlEditor.svcHelper.CreateElement(xmlEditor.documentId, nodeItemsId, 'inside', 'item', 'item', 'SOMITEM_COMPLEXTYPE');
			
						if (result != null)
						{
							result = result.replace(/<!\[ATADC\[/g, '<![CDATA[');
							result = result.replace(/\]ATADC\]>/g, ']]>');
												
												/* MsXml modif */
							newXmlDocument = new ActiveXObject("Msxml2.DOMDocument");
							
							newXmlDocument.async = false;
							newXmlDocument.resolveExternals = true;
							newXmlDocument.loadXML(result);
							
							nodeItems = newXmlDocument.selectSingleNode("//*[@xe:id = '" + nodeItemsId + "']");
							
							childrens = nodeItems.childNodes;
							nodeItem = childrens.item(childrens.length - 1);
						}
					}
					
					/* data */
					nodeData = nodeItem.selectSingleNode("data");
					if (nodeData != null)
					{
						nodeData.text = currentItemsList[i][0];
						id = nodeData.attributes.getNamedItem("xe:id").text;
						xmlEditor.svcHelper.SaveText(xmlEditor.documentId, id, nodeData.xml);
						
						/* display */
						nodeDisplay = nodeItem.selectSingleNode("display");
						nodeDisplay.text = currentItemsList[i][1];
						id = nodeDisplay.attributes.getNamedItem("xe:id").text;
						xmlEditor.svcHelper.SaveText(xmlEditor.documentId, id, nodeDisplay.xml);
					}									
				}
				
				if (nbChildrensOld > currentItemsList.length)
				{
					for(i = currentItemsList.length; i < childrensOld.length; i++)
					{
						/* delete Item */
						nodeItem = childrensOld.item(i);
						id = nodeItem.attributes.getNamedItem("xe:id").text;
						xmlEditor.svcHelper.DeleteElement(xmlEditor.documentId, id);
					}
				}
				
				xmlEditor.ReloadDocument();
			}
			
			function SaveDataSource()
			{
				var nodeDataSource;
				var nodeDataSourceId
				var nodeData;
				var nodeDisplay;
				var id;
				var newXmlDocument;
				
				nodeDataSource = xmlEditor.xmlDocument.selectSingleNode("//*[@xe:id = '" + currentId + "']/dataSource");
				
				if (currentDataSource[0] != '')
				{
					if (nodeDataSource == null)
					{
						result = xmlEditor.svcHelper.CreateElement(xmlEditor.documentId, currentId, 'inside', 'dataSource', 'dataSource', 'SOMITEM_COMPLEXTYPE');				
						
						/* MsXml modif */
						newXmlDocument = new ActiveXObject("Msxml2.DOMDocument");
						
						newXmlDocument.async = false;
						newXmlDocument.resolveExternals = true;
						newXmlDocument.setProperty("AllowXsltScript", true);
                        newXmlDocument.setProperty("AllowDocumentFunction", true);
						newXmlDocument.loadXML(result);
								
						nodeDataSource = newXmlDocument.selectSingleNode("//*[@xe:id = '" + currentId + "']/dataSource");
					}
					
					nodeDataSourceId = nodeDataSource.attributes.getNamedItem("xe:id").text;
					
					/* provider */
					nodeData = nodeDataSource.selectSingleNode("provider");
				
					if (nodeData == null)
					{
						result = xmlEditor.svcHelper.CreateElement(xmlEditor.documentId, nodeDataSourceId, 'inside', 'provider', 'provider', 'SOMITEM_SIMPLETYPE');
						if (result != null)
						{
							result = result.replace(/<!\[ATADC\[/g, '<![CDATA[');
							result = result.replace(/\]ATADC\]>/g, ']]>');
												
												/* MsXml modif */
							newXmlDocument = new ActiveXObject("Msxml2.DOMDocument");
							
							newXmlDocument.async = false;
							newXmlDocument.resolveExternals = true;
							newXmlDocument.setProperty("AllowXsltScript", true);
                            newXmlDocument.setProperty("AllowDocumentFunction", true);
							newXmlDocument.loadXML(result);
							
							nodeDataSource = newXmlDocument.selectSingleNode("//*[@xe:id = '" + nodeDataSourceId + "']");
							
							nodeData = nodeDataSource.selectSingleNode("provider");
						}
					}
					nodeData.text = currentDataSource[0];
					id = nodeData.attributes.getNamedItem("xe:id").text;
					xmlEditor.svcHelper.SaveText(xmlEditor.documentId, id, nodeData.xml);
					
					/* cachingName */
					nodeData = nodeDataSource.selectSingleNode("cachingName");
					if (nodeData == null)
					{
						result = xmlEditor.svcHelper.CreateElement(xmlEditor.documentId, nodeDataSourceId, 'inside', 'cachingName', 'text', 'SOMITEM_SIMPLETYPE');
						if (result != null)
						{
							result = result.replace(/<!\[ATADC\[/g, '<![CDATA[');
							result = result.replace(/\]ATADC\]>/g, ']]>');
												
												/* MsXml modif */
							newXmlDocument = new ActiveXObject("Msxml2.DOMDocument");
							
							newXmlDocument.async = false;
							newXmlDocument.resolveExternals = true;
							newXmlDocument.setProperty("AllowXsltScript", true);
                            newXmlDocument.setProperty("AllowDocumentFunction", true);
							newXmlDocument.loadXML(result);
							
							//alert(newXmlDocument.xml);
							nodeDataSource = newXmlDocument.selectSingleNode("//*[@xe:id = '" + nodeDataSourceId + "']");
													
							nodeData = nodeDataSource.selectSingleNode("cachingName");
						}
					}
					nodeData.text = currentDataSource[1];
					id = nodeData.attributes.getNamedItem("xe:id").text;
					xmlEditor.svcHelper.SaveText(xmlEditor.documentId, id, nodeData.xml);
					
					/* select */
					nodeData = nodeDataSource.selectSingleNode("select");
					if (nodeData == null)
					{
						result = xmlEditor.svcHelper.CreateElement(xmlEditor.documentId, nodeDataSourceId, 'inside', 'select', 'text', 'SOMITEM_SIMPLETYPE');
						if (result != null)
						{
							result = result.replace(/<!\[ATADC\[/g, '<![CDATA[');
							result = result.replace(/\]ATADC\]>/g, ']]>');
												
												/* MsXml modif */
							newXmlDocument = new ActiveXObject("Msxml2.DOMDocument");
							
							newXmlDocument.async = false;
							newXmlDocument.resolveExternals = true;
							newXmlDocument.setProperty("AllowXsltScript", true);
                            newXmlDocument.setProperty("AllowDocumentFunction", true);
							newXmlDocument.loadXML(result);
							
							nodeDataSource = newXmlDocument.selectSingleNode("//*[@xe:id = '" + nodeDataSourceId + "']");
							
							nodeData = nodeDataSource.selectSingleNode("select");
						}
					}
					nodeData.text = currentDataSource[2];
					id = nodeData.attributes.getNamedItem("xe:id").text;
					xmlEditor.svcHelper.SaveText(xmlEditor.documentId, id, nodeData.xml);
					
					/* parameter */
					nodeDataParameter = nodeDataSource.selectSingleNode("parameter");
					if (currentDataSource[3] != "")
					{
						if (nodeDataParameter == null)
						{
							result = xmlEditor.svcHelper.CreateElement(xmlEditor.documentId, nodeDataSourceId, 'inside', 'parameter', 'parameter', 'SOMITEM_COMPLEXTYPE');
							if (result != null)
							{
								result = result.replace(/<!\[ATADC\[/g, '<![CDATA[');
								result = result.replace(/\]ATADC\]>/g, ']]>');
													
													/* MsXml modif */
								newXmlDocument = new ActiveXObject("Msxml2.DOMDocument");
								
								newXmlDocument.async = false;
								newXmlDocument.resolveExternals = true;
								newXmlDocument.setProperty("AllowXsltScript", true);
                                newXmlDocument.setProperty("AllowDocumentFunction", true);
								newXmlDocument.loadXML(result);
								
								nodeDataSource = newXmlDocument.selectSingleNode("//*[@xe:id = '" + nodeDataSourceId + "']");
								
								nodeDataParameter = nodeDataSource.selectSingleNode("parameter");
							}
						}
						/* name */
						nodeData = nodeDataParameter.selectSingleNode("name");
						if (nodeData != null)
						{
							nodeData.text = currentDataSource[3];
							id = nodeData.attributes.getNamedItem("xe:id").text;
							xmlEditor.svcHelper.SaveText(xmlEditor.documentId, id, nodeData.xml);
						}
						/* type */
						nodeData = nodeDataParameter.selectSingleNode("type");
						if (nodeData != null)
						{
							nodeData.text = currentDataSource[4];
							id = nodeData.attributes.getNamedItem("xe:id").text;
							xmlEditor.svcHelper.SaveText(xmlEditor.documentId, id, nodeData.xml);
						}
						/* value */
						nodeData = nodeDataParameter.selectSingleNode("value");
						if (nodeData != null)
						{
							nodeData.text = currentDataSource[5];
							id = nodeData.attributes.getNamedItem("xe:id").text;
							xmlEditor.svcHelper.SaveText(xmlEditor.documentId, id, nodeData.xml);
						}
						
					}
					else
					{
						if (nodeDataParameter != null)
						{
							id = nodeDataParameter.attributes.getNamedItem("xe:id").text;
							xmlEditor.svcHelper.DeleteElement(xmlEditor.documentId, id);
						}
					}
					
					/* displayColumn */
					nodeData = nodeDataSource.selectSingleNode("displayColumn");
					if (nodeData == null)
					{
						result = xmlEditor.svcHelper.CreateElement(xmlEditor.documentId, nodeDataSourceId, 'inside', 'displayColumn', 'text', 'SOMITEM_SIMPLETYPE');
						if (result != null)
						{
							result = result.replace(/<!\[ATADC\[/g, '<![CDATA[');
							result = result.replace(/\]ATADC\]>/g, ']]>');
												
												/* MsXml modif */
							newXmlDocument = new ActiveXObject("Msxml2.DOMDocument");
							
							newXmlDocument.async = false;
							newXmlDocument.resolveExternals = true;
							newXmlDocument.setProperty("AllowXsltScript", true);
                            newXmlDocument.setProperty("AllowDocumentFunction", true);
							newXmlDocument.loadXML(result);
							
							nodeDataSource = newXmlDocument.selectSingleNode("//*[@xe:id = '" + nodeDataSourceId + "']");
							
							nodeData = nodeDataSource.selectSingleNode("displayColumn");
						}
					}
					nodeData.text = currentDataSource[6];
					id = nodeData.attributes.getNamedItem("xe:id").text;
					xmlEditor.svcHelper.SaveText(xmlEditor.documentId, id, nodeData.xml);
					
					/* filter */
					nodeData = nodeDataSource.selectSingleNode("filter");
					if (nodeData == null)
					{
						result = xmlEditor.svcHelper.CreateElement(xmlEditor.documentId, nodeDataSourceId, 'inside', 'filter', 'text', 'SOMITEM_SIMPLETYPE');
						if (result != null)
						{
							result = result.replace(/<!\[ATADC\[/g, '<![CDATA[');
							result = result.replace(/\]ATADC\]>/g, ']]>');
												
												/* MsXml modif */
							newXmlDocument = new ActiveXObject("Msxml2.DOMDocument");
							
							newXmlDocument.async = false;
							newXmlDocument.resolveExternals = true;
							newXmlDocument.setProperty("AllowXsltScript", true);
                            newXmlDocument.setProperty("AllowDocumentFunction", true);
							newXmlDocument.loadXML(result);
							
							nodeDataSource = newXmlDocument.selectSingleNode("//*[@xe:id = '" + nodeDataSourceId + "']");
							
							nodeData = nodeDataSource.selectSingleNode("filter");
						}
					}
					nodeData.text = currentDataSource[7];
					id = nodeData.attributes.getNamedItem("xe:id").text;
					xmlEditor.svcHelper.SaveText(xmlEditor.documentId, id, nodeData.xml);
					
					/* dataColumn */
					nodeData = nodeDataSource.selectSingleNode("dataColumn");
					if (nodeData == null)
					{
						result = xmlEditor.svcHelper.CreateElement(xmlEditor.documentId, nodeDataSourceId, 'inside', 'dataColumn', 'text', 'SOMITEM_SIMPLETYPE');
						if (result != null)
						{
							result = result.replace(/<!\[ATADC\[/g, '<![CDATA[');
							result = result.replace(/\]ATADC\]>/g, ']]>');
												
												/* MsXml modif */
							newXmlDocument = new ActiveXObject("Msxml2.DOMDocument");
							
							newXmlDocument.async = false;
							newXmlDocument.resolveExternals = true;
							newXmlDocument.setProperty("AllowXsltScript", true);
                            newXmlDocument.setProperty("AllowDocumentFunction", true);
							newXmlDocument.loadXML(result);
							
							nodeDataSource = newXmlDocument.selectSingleNode("//*[@xe:id = '" + nodeDataSourceId + "']");
							
							nodeData = nodeDataSource.selectSingleNode("dataColumn");
						}
					}
					nodeData.text = currentDataSource[8];
					id = nodeData.attributes.getNamedItem("xe:id").text;
					xmlEditor.svcHelper.SaveText(xmlEditor.documentId, id, nodeData.xml);
				}
				else
				{
					if (nodeDataSource != null)
					{
						id = nodeDataSource.attributes.getNamedItem("xe:id").text;
						xmlEditor.svcHelper.DeleteElement(xmlEditor.documentId, id);
					}
				}
									
				xmlEditor.ReloadDocument();
			}
			
			function UnLoading()
			{
				xmlEditor.dialog = null;
				xmlEditor.ProcessMouseOut();
  			}
  			
  			function FileUploaded(newUri, zipUri)
  			{
  			    var uris = newUri.split(";");
  			    var zipUris = zipUri.split(";");
  				var propertyInput;
  				var j = 0;
  				
  				propertyInput = document.all["xe_" + currentPropertyId];
                
                var uri = uris[0];
                if(uri == "")
                {
                    uri = zipUris[0];
                    j = 1;
                }
                
                propertyInput.value = uri;
				if (document.all["xe_" + currentPropertyId + "_Preview"] != null)
				{				
					//document.all["xe_" + currentPropertyId + "_Preview"].src = xmlEditor.xmlEditorPath + 'ImageThumbnail.aspx?uri=' +  xmlEditor.documentProviderName + ':' + newUri;
					document.all["xe_" + currentPropertyId + "_Preview"].src = '../WWW/GetFile.aspx?uri=' + ':' + encodeURIComponent(uri);
					document.all['xe_' + currentPropertyId + '_Preview'].style.display = '';
				}
    			
				if (xmlEditor.xmlDocument.selectSingleNode("//*[@xe:id = '" + currentId + "']").nodeName == "picturegallery")
				{
				    for(var i = 1; i < uris.length-1; i++)
				    {
				        if(zipUris[i] != "")
				            AddImage(uris[i], true);
				    }
				    for(; j < zipUris.length; j++)
				    {
				        if(zipUris[j] != "")
				            AddImage(zipUris[j], false);
				    }
				}
				currentPropertyId = null;
				currentFileUri = null;
				dialog = null;
				bFileUploaded = true;
				
  			}
  			
  			function AddImage(imageUrl, addToPropertiesScreen)
  			{
				var curId;
				var node;
				var children;
				var child;
				var label;
				var xeId;
				var html;
				var bFound;
				var isProperty;
				var curHeight;
				var curWidth;
				var enumeration;
				var fileUri;
				var address;
				var pos;
				var type;
				var bOpenDialog;
				var dataType;
  			    var args = xmlEditor.args;
                result = xmlEditor.svcHelper.CreateElement(xmlEditor.documentId, xmlEditor.element.children[0].xe_id, 'inside', args[1], args[2], args[3]);
                if (result != null) 
                {
				    result = result.replace(/<!\[ATADC\[/g, '<![CDATA[');
				    result = result.replace(/\]ATADC\]>/g, ']]>');
                    xmlEditor.xmlDocument.async = false;
				    xmlEditor.xmlDocument.resolveExternals = true;
				    xmlEditor.xmlDocument.setProperty("AllowXsltScript", true);
				    xmlEditor.xmlDocument.setProperty("AllowDocumentFunction", true);
				    xmlEditor.xmlDocument.loadXML(result);

				    if (xmlEditor.xmlDocument.parseError != 0) 
				    {
					    err(xmlEditor.GetLabelEditor('ERROR_loadingxmldocument') + ' ' + result);
					    xmlEditor.xmlDocument = null;
					    xmlEditor.ReloadDocument();
					    return false;
				    }
				    else 
				    {
					    oldId = xmlEditor.element.children[0].xe_id;
                        xmlEditor.UpdateHTML();
                        oldNode = xmlEditor.xmlDocument.selectSingleNode("//*[@xe:id = '" + oldId + "']");
                        newNode = oldNode.lastChild;
                        attribute = newNode.attributes.getNamedItem("xe:openPropertiesOnCreation");
                        this.lastUpdate = new Date();
                        this.bAllowEdition = true;
                        document.body.style.cursor = "default";
				    }
			    }
			    else 
			    {
				    err(xmlEditor.GetLabelEditor('ERROR_unabletoinsert'));
				    xmlEditor.ReloadDocument();
			    }
				try
				{
					bOpenDialog = true;
					curId = xmlEditor.element.children[0].xe_id;
					currentId = curId;
					node = newNode;
					bFound = false;
					if (node != null)
					{
						if (node.nodeName != 'field')
						{
							html = "";
							children = node.childNodes;

							for(var idx = 0; idx < children.length; idx++)
							{
								child = children.item(idx);
								if (child.nodeType == 1)
								{
									
									xeId = child.attributes.getNamedItem('xe:id');
									label = child.attributes.getNamedItem('xe:label');
									isProperty = child.attributes.getNamedItem('xe:property');
									hasEnumeration = child.attributes.getNamedItem('xe:hasEnumeration');
									schemaType = child.attributes.getNamedItem('xe:schemaType');
									hyperlinkType = child.attributes.getNamedItem('xe:hyperlinkType');
									dataType = child.attributes.getNamedItem('xe:dataType');
									
									if (isProperty != null)
									{
										if (isProperty.text == 'True')
										{
											properties.push(xeId.text);
											if (hasEnumeration.text == 'True')
											{
												
											}
											else
											{
											
												if (hyperlinkType == null)
												{
													
												}
												else
												{
													switch(hyperlinkType.value)
													{
														case 'localImage':
															if(child.text != '')
															{		
																html += '<tr style="' + (addToPropertiesScreen ? "" : " display:none;") + '" height="40"><td class="label" valign="middle"><nobr>' + xmlEditor.GetLabelElement(label.text) + '</nobr></td><td class="label" valign="middle">&nbsp;:&nbsp;</td><td class="value" valign="middle"><input id="xe_' + xeId.text +  '" type="hidden" value="' + child.text + '"></input><input type="button" value="' + xmlEditor.GetLabelEditor('update') + '" onclick="UpdateFile(\'' + xeId.text + '\', \'image\')"><input type="button" value="' + xmlEditor.GetLabelEditor('clear') + '" onclick="ClearFile(\'' + xeId.text + '\', \'image\')"></td><td><div style="width:150px;overflow:hidden;"><img id="xe_' + xeId.text +  '_Preview" onclick="PreviewImage(\'' + xeId.text + '\');" alt="' + xmlEditor.GetLabelEditor('preview') + '" src="../WWW/GetFile.aspx?uri=' + ':' + GetURI(child.text) + '" height="40" /></div></td></tr>';
															}
															else
															{
																html += '<tr style="' + (addToPropertiesScreen ? "" : " display:none;") + '" height="40" ><td class="label" valign="middle"><nobr>' + xmlEditor.GetLabelElement(label.text) + '</nobr></td><td class="label" valign="middle">&nbsp;:&nbsp;</td><td class="value" valign="middle"><input id="xe_' + xeId.text +  '" type="hidden" value="' + child.text + '"></input><input type="button" value="' + xmlEditor.GetLabelEditor('update') + '" onclick="UpdateFile(\'' + xeId.text + '\', \'image\')"><input type="button" value="' + xmlEditor.GetLabelEditor('clear') + '" onclick="ClearFile(\'' + xeId.text + '\', \'image\')"></td><td><div style="width:150px;overflow:hidden;"><img id="xe_' + xeId.text +  '_Preview" onclick="PreviewImage(\'' + xeId.text + '\');" alt="' + xmlEditor.GetLabelEditor('preview') + '" src="../WWW/GetFile.aspx?uri=' + ':<%= Application["ApplicationPath"] %>_SiteNote/Admin/Images/Transp.gif" height="40" /></div></td></tr>';
															}
														    break;
														case 'localFile':
															html += '<tr style="' + (addToPropertiesScreen ? "" : " display:none;") + '"><td class="label"><nobr>' + xmlEditor.GetLabelElement(label.text) + '</nobr></td><td class="label">&nbsp;:&nbsp;</td><td class="value" colspan="2"><input id="xe_' + xeId.text +  '" type="hidden" value="' + child.text + '"></input><input type="button" value="' + xmlEditor.GetLabelEditor('update') + '" onclick="UpdateFile(\'' + xeId.text + '\', \'file\')"></td></tr>';
															break;
													}
												}
											}
											
											bFound = true;
										}
									}
									else
									{
										//alert('error for : ' + child.xml);
									}
								}
							}
							
						}
						else
						{
						}							
					}
				
				
                    var htmlI = $("#content").children("table").children("tbody").html();
                    $("#content").children("table").children("tbody").html(htmlI +  html);
				}
				catch(e)
				{
					alert("You were delogged!");
					Close();
				}
				currentPropertyId = node.childNodes[0].attributes.getNamedItem('xe:id').nodeValue;
				propertyInput = document.all["xe_" + currentPropertyId];
                propertyInput.value = imageUrl;
				
			    if (document.all["xe_" + currentPropertyId + "_Preview"] != null)
			    {				
				    document.all["xe_" + currentPropertyId + "_Preview"].src = '../WWW/GetFile.aspx?uri=' + ':' + encodeURIComponent(imageUrl);
				    document.all['xe_' + currentPropertyId + '_Preview'].style.display = '';
			    }
  			}
  					
  			/*
  			function ItemsUpdated(items)
  			{
  				var propertyInput;
  				
  				propertyInput = document.all["xe_" + currentPropertyId];
  				//alert(propertyInput.value);
  				//alert(propertyInput.xml);

				propertyInput.value = "<item><display>x</display></data>y</data></item>";
				
				currentPropertyId = null;
				currentItemsListList = null;
				dialog = null;
				bItemsUploaded = true;
  			}
  			*/
  			
			function UploadCanceled()
			{
				currentPropertyId = null;
				currentFileUri = null;
				dialog = null;
			}

  			function OnFocus()
  			{
  				if (dialog != null)
  				{
  					if (!dialog.closed)
  					{
  						dialog.focus();
  						return;
  					}
  					dialog = null;
  				}
  			}
  			
  			window.attachEvent("onfocus", OnFocus);
			</script>
	</head>
	<body style="width:100%" onload="Loaded()" onunload="UnLoading()">
		<table id="Main" cellSpacing="0" cellPadding="0" border="0" style="height:100%;width:100%;">
			<tr height="31">
				<td colspan="5">
					<table border="0" cellpadding="0" cellspacing="0" height="100%" width="100%">
						<tr>
							<td width="100%">
								<table border="0" cellpadding="0" cellspacing="0" height="100%" width="100%">
									<tr>
										<td width="100%" background="Images/HeaderLeft.gif"><img src="Images/Transp.gif" height="1" width="100%"></td>
										<td align="right"><img src="Images/HeaderRight.gif"></td>
									</tr>
								</table>
							</td>
						</tr>
					</table>
				</td>
			</tr>
			<tr>
				<td width="7" background="Images/BackgroundLeft.gif"><img src="Images/Transp.gif" width="7"></td>
				<td width="7"><img src="Images/Transp.gif" width="7"></td>
				<td id="content" width="100%" height="100%" style="padding-bottom:7px;" valign="top" class="label"><%= pageResourceManager.GetString("loadingproperties")%>
				</td>
				<td width="7"><img src="Images/Transp.gif" width="7"></td>
				<td width="9" height="100%">
					<table border="0" cellpadding="0" cellspacing="0" width="9" height="100%">
						<tr height="32">
							<td width="9"><img src="Images/BackgroundTopRight.gif"></td>
						</tr>
						<tr height="100%">
							<td width="9" background="Images/BackgroundRight.gif"></td>
						</tr>
					</table>
				</td>
			</tr>
			<tr height="40">
				<td colspan="5">
					<table border="0" cellpadding="0" cellspacing="0" height="100%">
						<tr>
							<td height="8"><img src="Images/FooterLeft.gif"></td>
							<td width="100%">
								<table border="0" cellpadding="0" cellspacing="0" height="100%" width="100%">
									<tr>
										<td width="100%" background="Images/FooterCenter.gif" height="8"></td>
										<td height="8"><img src="Images/FooterRight.gif" width="255" height="8"></td>
									</tr>
								</table>
							</td>
						</tr>
						<tr>
							<td align="right" width="100%" colSpan="3">
								<table id="Table5" width="100%" height="100%" border="0" style="background :url(Images/Footer.gif) no-repeat right; ">
									<tr>
										<td width="100%"></td>
										<td><input id="Save" type="button" name="Save" value='<%= pageResourceManager.GetString("saveButton")%>' onclick="Save();" /></td>
										<td><input id="Cancel" type="button" name="Close" value='<%= pageResourceManager.GetString("cancelButton")%>' onclick="Close();" /></td>
										<td width="1"></td>
									</tr>
								</table>
							</td>
						</tr>
					</table>
				</td>
			</tr>
		</table>
	</body>
</html>
